import 'package:json_annotation/json_annotation.dart';

part 'response.g.dart';

@JsonSerializable(genericArgumentFactories: true)
class ResponseSuccess<T> {
  final int code;
  final String msg;
  final T? data;

  ResponseSuccess({required this.code, required this.msg, this.data});

  factory ResponseSuccess.fromJson(Map<String, dynamic> json, T Function(Object? json) fromJsonT) =>
      _$ResponseSuccessFromJson(json, fromJsonT);
  Map<String, dynamic> toJson(Object? Function(T value) toJsonT) =>
      _$ResponseSuccessToJson(this, toJsonT);
}

@JsonSerializable()
class ResponseError {
  final int code;
  final String msg;

  ResponseError({required this.code, required this.msg});

  factory ResponseError.fromJson(Map<String, dynamic> json) => _$ResponseErrorFromJson(json);
  Map<String, dynamic> toJson() => _$ResponseErrorToJson(this);
}